package samples.quotes;

import java.util.ArrayList;
import java.util.List;

import br.cin.ufpe.in1118.middleware.distribution.services.naming.Naming;
import br.cin.ufpe.in1118.middleware.distribution.services.naming.NamingService;
import br.cin.ufpe.in1118.middleware.exceptions.RemoteException;

public class QuotesClient {

	public static void main(String[] args) {
		Quotes quoter = null;
		Naming naming = NamingService.getNamingInstance("localhost", 9001);
		try {
			Object obj = naming.lookup(Quotes.SERVICE_NAME);
			if (obj instanceof Quotes) {
				quoter = (Quotes) obj;
			}
			
			List<Quote> fiveQuotes = new ArrayList<Quote>();
			for (int i = 0; i < 5; i++) {
				fiveQuotes.add(quoter.getRandomQuote());
			}
			
			for (Quote quote : fiveQuotes) {
				System.out.printf("Quote: %s\n", quote);
			}
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}

}
